<?php
	defined( "AZ_EXE_" ) or die ( "ERROR : CORE VARIABLE IS NOT DEFINED." );
	class Combo extends Element {
		public $listItems = array() ;
		public $selectedItem = "" ;
		public $defaultItem = "" ;
		public function __construct( $attributes = array() , $listItems = array() , $defaultItem = "" , $selectedItem = "" ){
			parent::__construct("select",$attributes);
			$this->listItems = $listItems ;
			$this->selectedItem = $selectedItem ;
			$this->defaultItem = $defaultItem ;
		}
		public function getCombo( $attributes = array() , $listItems = array() , $defaultItem = "" , $selectedItem = "" ){
			return new Combo( $attributes, $listItems , $defaultItem , $selectedItem );
		}
		public function setListItems( $listItems = array() ){
			$this->listItems = $listItems ;
		}
		public function setDefaultItem( $defaultItem = "" ){
			$this->defaultItem = $defaultItem ;
		}
		public function setSelectedItem ( $selectedItem = "" ){
			$this->selectedItem = $selectedItem ;
		}
		public function getElement(){
			$selectItems="";
			$this->defaultItem != ""?$selectItems = "<option value=\"\" >$this->defaultItem</option>":false;
			if(is_array($this->listItems)){
				foreach ( $this->listItems AS $key => $value ){
					if ( $key == $this->selectedItem ){
						$selectItems .="<option value=\"$key\" selected=\"selected\" >$value</option>" ;
					}
					else {
						$selectItems .="<option value=\"$key\" >$value</option>" ;
					}
				}
			}
			parent::setValue( $selectItems );
			return parent::getElement();
		}
	}
?>